//行政区域管理 显示表格及js实体

Ext.define('AreaModel', {
    extend: 'Ext.data.Model',
    fields: [
        "Id"	
		, "Code"   //区域编号
		, "Province"   //省份
		, "City"   //市
		, "County"   //县
		, "Level"   //行政级别
		, "Spell"   //拼音		 
	],
    idProperty: "Id"
});

Ext.define("SHApp.System.AdministrativeArea.AreaComboBox", {
    extend: "BLBTSystem.CmbData",
    alias: "widget.areaComboBox",
    dataUrl: "api/administrativeareaQ?format=json&Level=1",
    model: "AreaModel",
    matchFieldWidth: false,
    sorters: [{
        property: 'Code',
        direction: 'ASC'
    }],
    listConfig: {
        resizable: true,
        width: 300
    },
    minChars: 1,
    valueField: "Code",
    displayField: "Province",
    maxLength: 100,
    forceSelection: false,
    initComponent: function () {
        Ext.apply(this);
        this.callParent(arguments);
    },
    loadByProvince: function (province) {
        this.dataUrl = "api/administrativeareaQ?format=json&Level=2&Province=" + encodeURIComponent(province);
        this.reLoadData();
    },
    clearData: function () { 
        this.clearValue();
        this.store.removeAll();
    }
});
